import React from "react";
import { withRouter, Switch, Route, Redirect } from "react-router-dom";
const RouterView = (props) => {
    const { routerList } = props;
    return (
        <Switch>
            {
                routerList.map((item, index) => {
                    return item.component && !item.redirect ? <Route key={index} path={item.path} render={(props) => {
                        return <item.component route={item.children} {...props} />;
                    }} /> : <Redirect key={index} to={item.redirect} />;
                })
            }
        </Switch>
    )
};
export default withRouter(RouterView);